<template>
	<view class="container"> 
		<view class="pagetop">
			<u-navbar :is-back="false" :border-bottom="false">
				<u-icon name="/static/mine/icon_sz_186.png" size="20px" slot="right" @tap="navigateToSet()"></u-icon>
			</u-navbar>
			<view class="userinfo" v-if="isLogin==1">
				<view class="userinfo-left">
					<u-avatar :src="userInfo.headOrtrait" size="120"></u-avatar>
					<view class="usertexts">
						<text class="username">{{userInfo.name}}</text>
						<view class="useradd">
							<u-icon name="/static/mine/icon_dw_18.png" size="25"></u-icon>
							<text>徐州鼓楼区</text>
						</view>
					</view>
				</view>
				<view class="userinfo-right" @tap="navigateTomypage()">
					<text>个人主页</text>
					<u-icon name="/static/icon_zy_189.png" size="15"></u-icon>
				</view>
			</view>
			<view class="userinfo" v-if="isLogin==-1">
				<view class="userinfo-left" @tap="relaunchLogin()"> 
					<u-avatar src="/" size="120"></u-avatar>
					<view class="usertexts">
						<text class="notlogin">未登录</text>
						<view class="useradd">
							<u-icon name="/static/mine/icon_dw_18.png" size="25"></u-icon>
							<text>徐州鼓楼区</text>
						</view>
					</view>
				</view>
			</view>
			<view class="userrecords">
				<view class="recorditem" @tap='fourDetails(0)'>
					<text>{{nowUser.fabuNumber || 0}}</text>
					<text>发布</text>
				</view>
				<view class="recorditem" @tap='fourDetails(1)'>
					<text>{{nowUser.shoucangNumber || 0}}</text>
					<text>收藏</text>
				</view>
				<view class="recorditem" @tap='fourDetails(2)'>
					<text>{{nowUser.guanzhuNumber || 0}}</text>
					<text>关注</text>
				</view>
				<view class="recorditem" @tap='fourDetails(3)'>
					<text>{{nowUser.zujiNumber || 0}}</text>
					<text>足迹</text>
				</view>
			</view>
		</view>
		<view class="myorders">
			<view class="myorders-top" @tap='orderDetails(0)'>
				<text class="modaltitle">我的订单</text>
				<view class="ckmyorders">
					<text>查看全部订单</text>
					<u-icon name="/static/icon_zy_189.png" size="15"></u-icon>
				</view>
			</view>
			<view class="modal-bottom">
				<view class="modal-item" @tap='orderDetails(1)'>
					<image src="/static/mine/icon_yy_190.png" mode=""></image>
					<text>预约订单</text>
				</view>
				<view class="modal-item" @tap='orderDetails(2)'>
					<image src="/static/mine/order-icon.png" mode=""></image>
					<text>进行中</text>
				</view>
				<view class="modal-item" @tap='orderDetails(3)'>
					<image src="/static/mine/icon_pj_192.png" mode=""></image>
					<text>评价</text>
				</view>
				<view class="modal-item" @tap='orderDetails(4)'>
					<image src="/static/mine/icon_ss_193.png" mode=""></image>
					<text>退款/售后</text>
				</view>
			</view>
			<!-- <view class="workingworker-list">
				<view class="workingworker">
					 <image src="/static/avatar.jpg" mode=""></image>
					 <view class="workerinfo">
					 	<text class="workername">李师傅</text>
						<text class="workstatus">施工中...</text>
						<view class="workadd">
							<u-icon name="/static/mine/location.png" size="25"></u-icon>
							<text>徐州鼓楼区和信广场</text>
						</view>
					 </view>
				</view>
			</view> -->
		</view>
		<view class="gettxs">
			<image src="/static/mine/img_159_1.png" mode="" class="img1"></image>
			<image src="/static/mine/img_196.png" mode="" class="img2"></image>
		</view>
		<view class="usercenter">
			<text class="modal-title">个人中心</text>
			<view class="modal-bottom">
				<view class="modal-item" @tap="navigateToMywallet()">
					<image src="/static/mine/icon_qb_196.png" mode=""></image>
					<text>钱包</text>
				</view>
				<view class="modal-item">
					<image src="/static/mine/icon_yhq_197.png" mode="" class="recticon"></image>
					<text>优惠券</text>
				</view>
				<view class="modal-item">
					<image src="/static/mine/icon_jzb_198.png" mode=""></image>
					<text>记账本</text>
				</view>
				<view class="modal-item">
					<image src="/static/mine/icon_tk_199.png" mode="" class="recticon"></image>
					<text>施工图库</text>
				</view>
				<view class="modal-item">
					<image src="/static/mine/icon_ft_200.png" mode=""></image>
					<text>发帖</text>
				</view>
				<view class="modal-item">
					<image src="/static/mine/icon_dh_201.png" mode=""></image>
					<text>礼品兑换</text>
				</view>
			</view>
		</view>
		<view class="welfarearea">
			<text class="modal-title">福利专区</text>
			<view class="modal-bottom">
				<view class="modal-item">
					<image src="/static/mine/icon_qd_122.png" mode="" class="recticon"></image>
					<text>每日签到</text>
				</view>
				<view class="modal-item">
					<image src="/static/mine/icon_zp_123.png" mode=""></image>
					<text>幸运转盘</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getUser} from '@/apis/request.js'
	export default {
		data() {
			return {
				userInfo:{},
				isLogin:0,
				nowUser:''
			};
		},
		onShow() {
		    if(uni.getStorageSync('userInfo')){
				this.isLogin=1;
				this.userInfo=uni.getStorageSync('userInfo');
				this.getUserInfo()
			}else{  
				this.isLogin=-1;
			}
		},
		methods:{
			// 顶部四个详细跳转，足迹，发布...
			fourDetails(num){
				switch(num){
					case 0:
						uni.navigateTo({
							url:'mypage/mypage'
						})
						break;
					case 1:
						uni.navigateTo({
							url:'mypage/mypage'
						})
						break;
					case 2:
						uni.navigateTo({
							url:'follow/follow'
						})
						break;
					case 3:
						uni.navigateTo({
							url:'footprint/footprint'
						})
						break;
					default:
						break;
					
				}
			},
			// 订单详细
			orderDetails(num){
				switch(num){
					case 0:
						uni.navigateTo({
							url:'./order/order?type='+num
						})
						break;
					case 1:
						uni.navigateTo({
							url:'./order/order?type='+num
						})
						break;
					case 2:
						uni.navigateTo({
							url:'./order/order?type='+num
						})
						break;
					case 3:
						uni.navigateTo({
							url:'./order/order?type='+num
						})
						break;
					case 4:
						uni.navigateTo({
							url:'./refund/refund'
						})
						break;
					default:
						break;
					
				}
			},
			// 获取用户信息
			getUserInfo(){
				this.$http({
					url:getUser,
					method:'GET',
					header:{
						'Token':this.userInfo.token||''
					}
				})
				.then(res=>{
					console.log(res,'用户信息')
					this.nowUser = res[1].data.data
				})
			},
			relaunchLogin(){
				uni.navigateTo({
					url:'../login/login'
				});
			},
			navigateToSet(){
				uni.navigateTo({
					url:'set/set'
				})
			},
			navigateTomypage(){
				if(this.isLogin==-1){
					uni.showToast({
						icon:'none',
						title:'请先登录'
					});
					return ;
				}
				uni.navigateTo({
					url:'./mypage/mypage'
				})
			},
			navigateToMywallet(){
				if(this.isLogin==-1){
					uni.showToast({
						icon:'none',
						title:'请先登录'
					});
					return ;
				}
				uni.navigateTo({
					url:'./mywallet/mywallet'
				});
			}
		}
	}
</script>

<style lang="scss">
     page{
		 width: 100%;
		 height: 100%;
	 }
	 .container{
		 width: 100%;
		 min-height: 100%;
		 background-color: #F4F8FB;
		 padding-bottom: 44px;
		 .pagetop{
			 width: 100%;
			 height: auto;
			 background-color: #FFFFFF;
			 padding-bottom: 20rpx;
		 }
		 .userinfo{
			 width: 680rpx;
			 height: auto;
			 margin: auto;
			 display: flex;
			 justify-content: space-between;
			 .userinfo-left{width: 350rpx;height: auto;display: flex;align-items: center;}
			 .usertexts{width: 210rpx;margin-left: 20rpx;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
			 .username{font-size: 35rpx;}
			 .useradd{
				 color:#888;
				 font-size: 25rpx;
				 display: flex;
				 align-items: center;
				 text{margin-left: 10rpx;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
				 margin-top: 10rpx;
			}
			.userinfo-right{
				font-size: 25rpx;
				color: #888;
				display: flex;
				align-items: center;
				text{margin-right: 10rpx;}
			}
		 }
		 .userrecords{
			 width: 680rpx;
			 height: 100rpx;
			 margin: auto;
			 margin-top: 20rpx;
			 display: flex;
			 align-items: center;
			 justify-content: space-between;
			 .recorditem{width: 70rpx;font-size: 28rpx;color: #222222;display: flex;justify-content: center;flex-wrap: wrap;}
		 }
		 .myorders{
			 width: 100%;
			 background-color: #FFFFFF;
			 height: auto;
			 padding-bottom: 20rpx;
			 margin-top: 20rpx;
			 .myorders-top{
				 width: 680rpx;
				 height: 100rpx;
				 border-bottom: 1rpx solid #F1F1F1;
				 margin:auto;
				 display: flex;
				 justify-content: space-between;
				 align-items: center;
				 .ckmyorders{
					 display: flex;
					 align-items: center;
					 color: #888;
					 font-size: 25rpx;
					 text{margin-right: 10rpx;}
				}
			 }
			 .workingworker-list{
				 width: 100%;
				 height: auto;
				 .workingworker{
				 	border-radius: 10rpx;
				 	background-color: #F3F3F3;
				 	width: 640rpx;
				 	height: auto;
				 	padding-top: 15rpx;
				 	padding-bottom: 15rpx;
					margin: auto;
					margin-top: 20rpx;
					display: flex;
					image{width: 80rpx;height: 80rpx;margin-left: 15rpx;}
					.workerinfo{
						display: flex;
						flex-wrap: wrap;
						flex: 1;
						margin-left: 15rpx;
						text{
							width: 100%;
						}
					}
					.workername{font-size: 30rpx;}
					.workstatus{font-size: 25rpx;color: #888;margin-top: 5rpx;}
					.workadd{
						margin-top:5rpx;
						width: 100%;
						white-space:nowrap;
						overflow:hidden;
						text-overflow:ellipsis
						;font-size: 25rpx;
						display: flex;
						align-items: center;
						color: #888;
						text{margin-left: 5rpx;}
					  }
				 }
			 }
		 }
		 .modaltitle{
			 font-size: 30rpx;
		 }
		 .modal-bottom{
			 width: 100%;
			 height: auto;
			 display: flex;
			 flex-wrap: wrap;
			 .modal-item{
				 margin-left: 30rpx;
				 width: 150rpx;
				 display: flex;
				 flex-wrap: wrap;
				 justify-content: center;
				 font-size: 26rpx;
				 color: #222222;
				 margin-top: 20rpx;
				 image{width: 45rpx;height: 45rpx;}
				 text{width: 100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align: center;margin-top: 10rpx;}
			}
		 }
		 .gettxs{
			 width: 680rpx;
			 height: 120rpx;
			 background:url('/static/mine/banner_195.png') no-repeat;
			 background-size: 100% 100%;
			 display: flex;
			 justify-content: space-between;
			 align-items: center;
			 margin: auto;
			 margin-top: 20rpx;
			 .img1{width: 120rpx;height: 110rpx;margin-left: 50rpx;align-self: flex-end;}
			 .img2{width: 100rpx;height: 100rpx;margin-right: 20rpx;}
		 }
		 .usercenter{
			 background-color: #fff;
			 margin-top: 20rpx;
			 width: 100%;
			 height: auto;
			 padding-top: 20rpx;
			 padding-bottom: 20rpx;
			 
		 }
		 .recticon{
		    width: 50rpx !important;
		 }
		 .modal-title{display:block;width: 680rpx;font-size: 30rpx;margin: auto;}
		 .welfarearea{
			 width: 100%;
			 height: auto;
			 background-color: #FFFFFF;
			 padding-top: 20rpx;
			 padding-bottom: 20rpx;
			 margin-top: 20rpx;
			 margin-bottom: 30rpx;
		 }
		 .notlogin{
			 font-size: 40rpx;
		 }
	 }
</style>
